using System.ServiceModel;
using StructureMap.Pipeline;

namespace StructureMap.WcfIntegration
{
    public class WCFContextCacheExtension : IExtension<InstanceContext>
    {
        private MainObjectCache cache;

        public IObjectCache Cache
        {
            get { return cache; }
        }

        public static WCFContextCacheExtension Current
        {

            get
            {
                return OperationContext.Current.
                    InstanceContext.Extensions.Find<WCFContextCacheExtension>();
            }

        }
        public void Attach(InstanceContext owner)
        {
            cache = new MainObjectCache();
        }

        public void Detach(InstanceContext owner)
        {

        }
    }
}